package utils;

import com.unipv14.androidgallery.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface.OnClickListener;
import android.view.LayoutInflater;

public class DialogCreator {

	/**
	 * 
	 * Crea una finestra di dialogo
	 * 
	 * @param currentActivity
	 * @param dialog
	 * @param messageName
	 * @param resource
	 * @param listener
	 */
	public void createDialogWindow(Activity currentActivity,
			AlertDialog dialog, int messageName, int resource,
			OnClickListener listener) {

		AlertDialog.Builder builder = new AlertDialog.Builder(currentActivity);
		builder.setMessage(messageName);
		builder.setPositiveButton(R.string.confirm, listener);
		builder.setNegativeButton(R.string.cancel, null);
		LayoutInflater inflater = currentActivity.getLayoutInflater();
		builder.setView(inflater.inflate(resource, null));
		dialog = builder.create();
		dialog.show();

	}

}
